package com.seecen.HJM.controller;

import com.seecen.HJM.model.dto.CommentPlaylistDTO;
import com.seecen.HJM.model.dto.CommentSongDTO;
import com.seecen.HJM.model.dto.CommentSongDto2;
import com.seecen.HJM.model.vo.CommentVo2;
import com.seecen.HJM.result.DataVo;
import com.seecen.HJM.result.PageResult;
import com.seecen.HJM.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author sunpingli
 * @since 2025-01-09
 */
@RestController
@RequestMapping("/comment")
public class CommentController {

    @Autowired
    private CommentService commentService;


    // 新增歌曲评论
    @PostMapping("/addSongComment")
    public DataVo addSongComment(@RequestBody CommentSongDTO commentSongDTO) {
        return commentService.addSongComment(commentSongDTO);
    }

    //新增歌单评论
    @PostMapping("/addPlaylistComment")
    public DataVo addPlaylistComment(@RequestBody CommentPlaylistDTO commentPlaylistDTO) {
        return commentService.addPlaylistComment(commentPlaylistDTO);
    }

    // 点赞评论
    @PatchMapping("/likeComment/{id}")
    public DataVo likeComment(@PathVariable("id") Long commentId) {
        return commentService.likeComment(commentId);
    }

    //取消点赞评论

    @PatchMapping("/cancelLikeComment/{id}")
    public DataVo cancelLikeComment(@PathVariable("id") Long commentId) {
        return commentService.cancelLikeComment(commentId);
    }

    //前台删除评论
    @DeleteMapping("/deleteComment/{id}")
    public DataVo deleteComment(@PathVariable("id") Long commentId) {
        return commentService.deleteComment(commentId);
    }


    // 获取歌曲评论列表
    @PostMapping("/getSongComments")
    public DataVo<PageResult<CommentVo2>> getSongComments(@RequestBody CommentSongDto2 commentSongDto) {
        return commentService.getSongComments(commentSongDto);
    }

    //前台删除歌曲评论
    @DeleteMapping("/deleteSongComment/{commentId}")
    public DataVo deleteSongComment(@PathVariable("commentId") Long commentId) {
        return commentService.deleteSongComment(commentId);
    }




}
